#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
@file_name: cpu_bound_code_with_task.py
@date: 2025-07-28 14:48
@author: Falling Snow
@desc: 和task一起运行的cpu密集型的程序测试
"""

import asyncio

from util import async_timed, delay


@async_timed()
async def cpu_bound_work() -> int:
    counter = 0
    for i in range(100_000_000):
        counter += 1
    return counter


@async_timed()
async def main():
    task_one = asyncio.create_task(cpu_bound_work())
    task_two = asyncio.create_task(cpu_bound_work())
    delay_task = asyncio.create_task(delay(4))

    await task_one
    await task_two
    await delay_task


if __name__ == '__main__':
    asyncio.run(main())
